package com.skyhub.service.impl;

import com.skyhub.common.domain.dto.HeatMap;
import com.skyhub.common.domain.dto.UploadFormDto;
import com.skyhub.common.domain.pojo.Article;
import com.skyhub.common.domain.pojo.ArticleSeries;
import com.skyhub.common.domain.pojo.User;
import com.skyhub.mapper.HomeMapper;
import com.skyhub.mapper.UploadMapper;
import com.skyhub.service.UploadService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class UploadServiceImpl implements UploadService {

    private final UploadMapper uploadMapper;

    private final HomeMapper homeMapper;
    @Override
    public List<ArticleSeries> series(UploadFormDto uploadFormDto){

        List<ArticleSeries>series=uploadMapper.series(uploadFormDto);

        return series;
    }

    @Override
    public void addSeries(UploadFormDto uploadFormDto) {
        uploadMapper.addSeries(uploadFormDto);
    }

    @Override
    public void insertIntoArticles(Article article,Integer userId){

        HeatMap heatMap=new HeatMap();

        heatMap.setUserId(userId);

        heatMap.setCount(1);

        uploadMapper.insertIntoHeatMap(heatMap);

        homeMapper.addArticleCount(userId);

        uploadMapper.insertIntoArticles(article);
    }
}
